/*
 * Copyright © 2010 Siddhanathan S.
 *
 * This file is part of JTeacher.
 *
 * JTeacher is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation version 3 of the License, or
 * any later version.
 *
 * JTeacher is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JTeacher.  If not, see <http://www.gnu.org/licenses/>.
 */

package jteacher;

/**
 * Class with the main lessons
 *
 * @author Siddhanathan S.
 */
public class Lessons {

    private static String n = "\n" ;

    private String jteacher,
	    objectConcept, whatsObject, implementObject,
	    variables, localVar, globalVar, instanceVar;

    Object[] getTreeStructure() {

	Object[] hierarchy = {
	    "JTeacher",
	    new Object[] {
		"Concept of Objects",
		"What is an Object",
		"Implementing Objects"
	    },
	    new Object[] {
		"Variables",
		"Local Variables",
                "Global Variables",
                "Instance Variables"
	    },
	    new Object[] {
		"Conditional Statements",
                 new Object[] {
		    "Decision Making Statements",
		    "If Else Sequence",
                    "Nested If Else",
		    "If Ladder",
		    "Ternary Operator"
		}
	    }
	};

	return hierarchy;
    }

    public Lessons() {

	jteacher = "JTeacher is a java application that aims at teaching the user several java concepts." ;

	objectConcept = "The main aim of any programming language is bring a part of the real world into the virtual world."
		+ n + "This may not sound very clear, but as you learn to program you'll realize this concept."
		+ n + "The main advantage of this is that learning the programming language will not feel like learning a new language."
		+ n
		+ n + "For eg. the computer understands only binary code i.e. 0s and 1s. "
		+ n + "We don't understand binary code so writing software with just 0s and 1s will be a big headache."
		+ n + "That's why we have programming languages to let us write in a language that we find understandable."
		+ n + "We understand real world objects because they are a part of our life."
		+ n + "To implement real world like objects into programming, Java follows OOP(Object Oriented Programming)";

	whatsObject = "An object is an entity having specific identity, characteristics and behaviour."
		+ n + "The state of an object is represented through values/attributes of its characteristics at a given point of time."
		+ n
		+ n + "Encapsulation is the wrapping up of data(characteristics) and functions(behaviour) into a single unit(called class)."
		+ n + "Objects encapsulate state and behaviour."
		+ n
		+ n + "Abstraction refers to the act of representing essential features without including the background details or explanations.";

	variables = "Variables are storage locations" ;

	localVar = "Local Variables are declared within a function body(block) or other blocks."
		+ n + "Their scope is limited to the block of the method in which they are declared."
		+ n + "They are temporary working variables." ;
    
	globalVar = "Global variables are declared within the class."
		+ n + "They are accessible by the entire class and its members."
		+ n + "They are variables of interest to the users of the class." ;
    
	instanceVar = "Instance variables are defined in a class (i.e. a member variable)"
		+ n + "Each object of the class has a separate copy of the instance variable."
		+ n + "The default value of instance variables are set inside a constructor." ;

    }

    public String nodeUpdate(Object nodeInfo) {

	if(nodeInfo == "JTeacher") {
	    return jteacher;
	} else if(nodeInfo == "Concept of Objects") {
	    return objectConcept;
	} else if (nodeInfo == "Variables") {
	    return variables ;

	} else if (nodeInfo == "Local Variables") {
	    return localVar;

	} else if (nodeInfo == "Global Variables") {
	    return globalVar;

	} else if (nodeInfo == "Instance Variables") {
	    return instanceVar;

	} else {
	    return "Please Choose an option";

	}
    }

}
